package net.sh.dpinfrastructure.support.spring.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import net.sh.dpinfrastructure.config.DPConfig;
import net.sh.dpinfrastructure.mongo.DPMongoSource;
import net.sh.dpinfrastructure.support.global.DPIDGenerateService;
import net.sh.dpinfrastructure.support.global.DPIDGenerateServiceUseMongo;

/**
 * 
 * 基础设施服务类配置类
 * 
 * @version 1.0
 * @since JDK1.7
 * @author shaohui
 * @company 上海朝阳永续信息技术有限公司
 * @copyright (c) 2016 SunTime Co'Ltd Inc. All rights reserved.
 * @date 2016年8月8日 下午3:10:05
 */
@Configuration
@Import(DPMongodbConfiguration.class)
public class DPIDGenerateServiceUseMongoConfiguration {

    @Bean
    public DPIDGenerateService getDPIDGenerateService(DPMongoSource mongo, DPConfig config) {
        String collectionName = config.get("global.idgenerater.mongo.collection");
        return new DPIDGenerateServiceUseMongo(mongo.getCollection(collectionName));
    }
    
}
